package net.minecraft.src;

import java.net.HttpURLConnection;
import java.net.URL;
import javax.imageio.ImageIO;
import net.minecraft.src.ImageBuffer;
import net.minecraft.src.ThreadDownloadImageData;

class ThreadDownloadImage extends Thread {

   // $FF: synthetic field
   final String location;
   // $FF: synthetic field
   final ImageBuffer buffer;
   // $FF: synthetic field
   final ThreadDownloadImageData imageData;


   ThreadDownloadImage(ThreadDownloadImageData var1, String var2, ImageBuffer var3) {
      super();
      this.imageData = var1;
      this.location = var2;
      this.buffer = var3;
   }

   public void run() {
      HttpURLConnection var1 = null;
      boolean var6 = false;

      label75: {
         label76: {
            try {
               var6 = true;
               URL var2 = new URL(this.location);
               var1 = (HttpURLConnection)var2.openConnection();
               var1.setDoInput(true);
               var1.setDoOutput(false);
               var1.connect();
               if(var1.getResponseCode() / 100 == 4) {
                  var6 = false;
                  break label75;
               }

               if(this.buffer == null) {
                  this.imageData.image = ImageIO.read(var1.getInputStream());
                  var6 = false;
               } else {
                  this.imageData.image = this.buffer.parseUserSkin(ImageIO.read(var1.getInputStream()));
                  var6 = false;
               }
               break label76;
            } catch (Exception var7) {
               var7.printStackTrace();
               var6 = false;
            } finally {
               if(var6) {
                  var1.disconnect();
               }
            }

            var1.disconnect();
            return;
         }

         var1.disconnect();
         return;
      }

      var1.disconnect();
   }
}
